import { Toast } from "vant"
import {
    createGroup
} from "@/request/create-group-request"

export const useCreateGroup = async (group_creator,group_name) => {
    try{
        if(group_name.value.length <= 0){
            return Toast("群名不能为空")
        }
        const result = await createGroup(group_creator,group_name.value);
        if(result.code === 201 && result.message === "success"){
            Toast("创建成功")
            group_name.value = "";
        }else{
            Toast("创建失败")
        }
    }catch(error){
        Toast(error.message)
    }
}